package com.changgou.goods.feign;

import com.changgou.goods.pojo.Sku;
import com.changgou.goods.pojo.Spu;
import com.changgou.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/*****
 * @Author: 黑马训练营
 * @Description: com.changgou.goods.feign
 ****/
@FeignClient(name = "goods")
@RequestMapping(value = "/sku")
public interface SkuFeign {

    /****
     * 查询所有商品
     */
    @GetMapping(value = "/status/{status}")
    Result<List<Sku>> findByStatus(@PathVariable(value = "status")String status);

    /**
     * 根据条件搜索
     * @param sku
     * @return
     */
    @PostMapping(value = "/search" )
    Result<List<Sku>> findList(@RequestBody(required = false) Sku sku);

    /***
     * 根据商品(Sku)ID查询商品详情
     */
    @GetMapping("/{id}")
    Result<Sku> findById(@PathVariable String id);


    /***
     * 库存递减实现
     * @param map
     * @return
     */
    @GetMapping(value = "/decr/count")
    Result decrCount(@RequestParam Map<String,Integer> map);

}
